package tier1;

import java.rmi.RemoteException;
import java.util.List;

import javax.swing.DefaultListModel;
import javax.swing.ListModel;

import tier3.Utilisateur;

public  class ClientThread extends Client implements Runnable{

	private int indexselection;
	public  ClientThread(){
	}
	public void run() {   	
		while(true){		
			try {			
				if(userAuthentifier!=null){
					List<String> listeamis = service.demandeListeConnecte(userAuthentifier);				
					if (listeamis!=null){
						getConteneurListeAmis().setVisible(true);
						indexselection=list.getSelectedIndex();
						listModel.removeAllElements();
						listModel.addElement("");
					
						for (String u : listeamis) {			
							listModel.addElement(u);
						}
						list.setSelectedIndex(indexselection);
						
					}
					else{
						System.out.println("c'est null");
					}
				}
				Thread.sleep(3000);
			}
			catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (RemoteException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}


